<html>
<body onload = "load();">
</body>
<script>

var singleton = function(fn){
    var result;
    return function() {
        return result || ( result = fn.apply(this,arguments));
    }
};

var createMask = singleton(function(){
  return document.body.appendChild(document.createElement('div'));
});

function load() {
	createMask();
	createMask();
}
</script>
</html>